*******************************************************************************************************************************
* Replication code for Bøttkjær & Justesen "Why do voters support corrupt politicians? Experimental evidence from South Africa"
*******************************************************************************************************************************

*This do-file includes all the recodings necsessary for running the analyses. 
*Please run this do-file before running any of the analyses in the paper or appendix.

clear
*use "replicationJOPdataverse.dta"

***generate outcome variable from responses to experiment Q43A-E.
gen outcome43 = Q43A
replace outcome43 = Q43B if Q43B!=.
replace outcome43 = Q43C if Q43C!=.
replace outcome43 = Q43D if Q43D!=.
replace outcome43 = Q43E if Q43E!=.

*recode "Don't know" as missing and define labels. 
recode outcome43 99=.
label define OUTCOME43 0 "Very unlikely" 1 "Unlikely" 2 "Neither" 3 "Likely" 4 "Very likely"
label values outcome43 OUTCOME43

***define labels for Q43 random treatment assignment. 
label define qr43 1 "Not corrupt" 2 "Corrupt" 3 "ANC" 4 "DA" 5 "Patronage"
label values QR43 qr43

* Swing/non-partisan // DK coded as non-partisan; refused coded as missing
recode Q7 (0=1) (99=1) (98=.) (else=0), gen(swing)
tab swing

* ANC partisans
recode Q8 (3=1) (else=0), gen(anc_partisan)
replace anc_partisan=. if Q7==98

label define anc_label 1 "ANC" 0 "Other" 
label values anc_partisan anc_label

* DA partisans
recode Q8 (8=1) (else=0), gen(da_partisan)
replace da_partisan=. if Q7==98

label define da_label 1 "DA" 0 "Other" 
label values da_partisan da_label

*****recoding of covariates.

***recoding "Living Standard Measures" - LSM - to minimum value = 0.
gen LSM14_0 = LSM14-2
tab LSM14_0
label var LSM14_0 "LSM (recoded)"

***recoding "Lived poverty index" - LPI - to a poverty scale 0-100. 
*food
recode Q2A (99=.), gen(food)

*water
recode Q2B (99=.), gen(water)

*medicine
recode Q2C (99=.), gen(medicine)

*fuel
recode Q2D (99=.), gen(fuel)

*cash
recode Q2E (99=.), gen(cash)

*electricity
recode Q2F (99=.), gen(el)

*sum LPI measures to make one index. 
gen poverty = food + water + medicine + fuel + cash + el

*change scale into 0-10.
gen poverty100 = ((poverty - 6)/24)*100
label var poverty100 "Poverty scaled 0-100"

***education
recode Q79 (98/99=.), gen(edu)

***gender, female as 1.
gen female = Gender
recode female (1=0) (2=1)

***urban (urban versus rural area)
recode Urban_Ru (1=1) (2=0), gen(urban)

***racial group
*recode racial group as one variable.
recode Q98 (1=0) (2/3=1) (4=2), gen(racialgroup)

*recode racial group as seperate dummy variables for appendix.
gen race_black=Q98
recode race_black (1=1) (.=.) (else=0)

gen race_white=Q98
recode race_white (4=1) (.=.) (else=0)

gen race_coloured=Q98
recode race_coloured (2/3=1) (.=.) (else=0)

***province, recode into dummy variables to use in summary stats.
gen easterncape=Province
recode easterncape (1=1) (.=.) (else=0)

gen freestate=Province
recode freestate (2=1) (.=.) (else=0)

gen gauteng=Province
recode gauteng (3=1) (.=.) (else=0)

gen kwazulunatal=Province
recode kwazulunatal (4=1) (.=.) (else=0)

gen limpopo=Province
recode limpopo (5=1) (.=.) (else=0)

gen mpumalanga=Province
recode mpumalanga (6=1) (.=.) (else=0)

gen northerncape=Province
recode northerncape (7=1) (.=.) (else=0)

gen northwest=Province
recode northwest (8=1) (.=.) (else=0)

gen westerncape=Province
recode westerncape (9=1) (.=.) (else=0)

***unemployment 
recode Q81 (5/6=1) (98=.) (else=0), gen(unemp)
label var unemp "Unemployed"

***information/knowledge
*info about the second largest party in SA.
recode Q75 (2=1) (else=0), gen(info_da)

*info about official unemployment rate.
recode Q76 (2=1) (else=0), gen(info_unemp)

*info about finance minister.
recode Q77 (5=1) (else=0), gen(info_finance)

*info about biggest tradepartner.
recode Q78 (1=1) (else=0), gen(info_trade)

*create final info variable. 
gen info = info_da + info_unemp + info_finance + info_trade

***other covariates by variable names: Gender, Age, Province

***municipality-level election results: ANC vote vs. DA vote
* Source: http://www.elections.org.za/content/Elections/Municipal-elections-results/

**generate variable.
gen ANCvote2016=.
gen DAvote2016=.

**replace from IEC data.
replace ANCvote2016 =0.83 if Local_Mu=="Albert Luthuli" 
replace DAvote2016 =0.03 if Local_Mu=="Albert Luthuli" 

replace ANCvote2016 =0.78 if Local_Mu=="Amahlathi" 
replace DAvote2016 =0.09 if Local_Mu=="Amahlathi" 

replace ANCvote2016 =0.68 if Local_Mu=="Ba-Phalaborwa" 
replace DAvote2016 =0.11 if Local_Mu=="Ba-Phalaborwa" 

replace ANCvote2016 =0.52 if Local_Mu=="Bela-Bela" 
replace DAvote2016 =0.27 if Local_Mu=="Bela-Bela" 

replace ANCvote2016 =0.59 if Local_Mu=="Buffalo City" 
replace DAvote2016 =0.23 if Local_Mu=="Buffalo City" 

replace ANCvote2016 =0.69 if Local_Mu=="Bushbuckridge" 
replace DAvote2016 =0.03 if Local_Mu=="Bushbuckridge" 

replace ANCvote2016 =0.36 if Local_Mu=="Cederberg" 
replace DAvote2016 =0.55 if Local_Mu=="Cederberg" 

replace ANCvote2016 =0.24 if Local_Mu=="City of Cape Town" 
replace DAvote2016 =0.67 if Local_Mu=="City of Cape Town" 

replace ANCvote2016 =0.45 if Local_Mu=="City of Johannesburg" 
replace DAvote2016 =0.38 if Local_Mu=="City of Johannesburg" 

replace ANCvote2016 =0.60 if Local_Mu=="City of Matlosana" 
replace DAvote2016 =0.21 if Local_Mu=="City of Matlosana" 

replace ANCvote2016 =0.41 if Local_Mu=="City of Tshwane" 
replace DAvote2016 =0.43 if Local_Mu=="City of Tshwane" 

replace ANCvote2016 =0.57 if Local_Mu=="Dannhauser" 
replace DAvote2016 =0.05 if Local_Mu=="Dannhauser" 

replace ANCvote2016 =0.63 if Local_Mu=="Dihlabeng" 
replace DAvote2016 =0.21 if Local_Mu=="Dihlabeng" 

replace ANCvote2016 =0.67 if Local_Mu=="Dikgatlong" 
replace DAvote2016 =0.18 if Local_Mu=="Dikgatlong" 

replace ANCvote2016 =0.62 if Local_Mu=="Ditsobotla" 
replace DAvote2016 =0.18 if Local_Mu=="Ditsobotla" 

replace ANCvote2016 =0.68 if Local_Mu=="Dr JS Moroka" 
replace DAvote2016 =0.06 if Local_Mu=="Dr JS Moroka" 

replace ANCvote2016 =0.24 if Local_Mu=="Drakenstein" 
replace DAvote2016 =0.66 if Local_Mu=="Drakenstein" 

replace ANCvote2016 =0.49 if Local_Mu=="Ekurhuleni" 
replace DAvote2016 =0.34 if Local_Mu=="Ekurhuleni"

replace ANCvote2016 =0.70 if Local_Mu=="Emakhazeni" 
replace DAvote2016 =0.18 if Local_Mu=="Emakhazeni" 

replace ANCvote2016 =0.60 if Local_Mu=="Emalahleni" 
replace DAvote2016 =0.25 if Local_Mu=="Emalahleni" 

replace ANCvote2016 =0.56 if Local_Mu=="Emfuleni" 
replace DAvote2016 =0.25 if Local_Mu=="Emfuleni" 

replace ANCvote2016 =0.83 if Local_Mu=="Engcobo" 
replace DAvote2016 =0.02 if Local_Mu=="Engcobo" 

replace ANCvote2016 =0.61 if Local_Mu=="Ephraim Mogale" 
replace DAvote2016 =0.07 if Local_Mu=="Ephraim Mogale" 

replace ANCvote2016 =0.65 if Local_Mu=="Ga-Segonyana" 
replace DAvote2016 =0.10 if Local_Mu=="Ga-Segonyana" 

replace ANCvote2016 =0.57 if Local_Mu=="Govan Mbeki" 
replace DAvote2016 =0.24 if Local_Mu=="Govan Mbeki" 

replace ANCvote2016 =0.71 if Local_Mu=="Great Kei" 
replace DAvote2016 =0.19 if Local_Mu=="Great Kei" 

replace ANCvote2016 =0.81 if Local_Mu=="Greater Giyani" 
replace DAvote2016 =0.03 if Local_Mu=="Greater Giyani" 

replace ANCvote2016 =0.65 if Local_Mu=="Greater Taung" 
replace DAvote2016 =0.04 if Local_Mu=="Greater Taung" 

replace ANCvote2016 =0.68 if Local_Mu=="Greater Tubatse" 
replace DAvote2016 =0.05 if Local_Mu=="Greater Tubatse" 

replace ANCvote2016 =0.75 if Local_Mu=="Greater Tzaneen" 
replace DAvote2016 =0.09 if Local_Mu=="Greater Tzaneen" 

replace ANCvote2016 =0.51 if Local_Mu=="Ikwezi" 
replace DAvote2016 =0.47 if Local_Mu=="Ikwezi" 

replace ANCvote2016 =0.81 if Local_Mu=="Intsika Yethu" 
replace DAvote2016 =0.02 if Local_Mu=="Intsika Yethu"

replace ANCvote2016 =0.71 if Local_Mu=="Joe Morolong" 
replace DAvote2016 =0.04 if Local_Mu=="Joe Morolong" 

replace ANCvote2016 =0.74 if Local_Mu=="Kagisano/Molopo" 
replace DAvote2016 =0.07 if Local_Mu=="Kagisano/Molopo" 

replace ANCvote2016 =0.59 if Local_Mu=="Khara Hais" 
replace DAvote2016 =0.31 if Local_Mu=="Khara Hais" 

replace ANCvote2016 =0.63 if Local_Mu=="King Sabata Dalindyebo" 
replace DAvote2016 =0.04 if Local_Mu=="King Sabata Dalindyebo" 

replace ANCvote2016 =0.32 if Local_Mu=="Knysna" 
replace DAvote2016 =0.50 if Local_Mu=="Knysna" 

replace ANCvote2016 =0.41 if Local_Mu=="Kouga" 
replace DAvote2016 =0.56 if Local_Mu=="Kouga" 

replace ANCvote2016 =0.64 if Local_Mu=="KwaDukuza" 
replace DAvote2016 =0.19 if Local_Mu=="KwaDukuza" 

replace ANCvote2016 =0.26 if Local_Mu=="Langeberg" 
replace DAvote2016 =0.50 if Local_Mu=="Langeberg" 

replace ANCvote2016 =0.74 if Local_Mu=="Lukanji" 
replace DAvote2016 =0.13 if Local_Mu=="Lukanji" 

replace ANCvote2016 =0.54 if Local_Mu=="Madibeng" 
replace DAvote2016 =0.20 if Local_Mu=="Madibeng" 

replace ANCvote2016 =0.61 if Local_Mu=="Mafikeng" 
replace DAvote2016 =0.10 if Local_Mu=="Mafikeng" 

replace ANCvote2016 =0.75 if Local_Mu=="Makhado" 
replace DAvote2016 =0.11 if Local_Mu=="Makhado" 

replace ANCvote2016 =0.68 if Local_Mu=="Makhuduthamaga" 
replace DAvote2016 =0.03 if Local_Mu=="Makhuduthamaga" 

replace ANCvote2016 =0.67 if Local_Mu=="Maluti a Phofung" 
replace DAvote2016 =0.08 if Local_Mu=="Maluti a Phofung" 

replace ANCvote2016 =0.59 if Local_Mu=="Mamusa" 
replace DAvote2016 =0.06 if Local_Mu=="Mamusa" 

replace ANCvote2016 =0.57 if Local_Mu=="Mangaung" 
replace DAvote2016 =0.26 if Local_Mu=="Mangaung" 

replace ANCvote2016 =0.74 if Local_Mu=="Matatiele" 
replace DAvote2016 =0.09 if Local_Mu=="Matatiele" 

replace ANCvote2016 =0.62 if Local_Mu=="Matjhabeng" 
replace DAvote2016 =0.22 if Local_Mu=="Matjhabeng" 

replace ANCvote2016 =0.81 if Local_Mu=="Mbizana" 
replace DAvote2016 =0.04 if Local_Mu=="Mbizana" 

replace ANCvote2016 =0.76 if Local_Mu=="Mbombela" 
replace DAvote2016 =0.14 if Local_Mu=="Mbombela" 

replace ANCvote2016 =0.45 if Local_Mu=="Metsimaholo" 
replace DAvote2016 =0.29 if Local_Mu=="Metsimaholo" 

replace ANCvote2016 =0.75 if Local_Mu=="Mnquma" 
replace DAvote2016 =0.05 if Local_Mu=="Mnquma" 

replace ANCvote2016 =0.64 if Local_Mu=="Mogalakwena" 
replace DAvote2016 =0.09 if Local_Mu=="Mogalakwena" 

replace ANCvote2016 =0.49 if Local_Mu=="Mogale City" 
replace DAvote2016 =0.35 if Local_Mu=="Mogale City" 

replace ANCvote2016 =0.48 if Local_Mu=="Mookgopong" 
replace DAvote2016 =0.24 if Local_Mu=="Mookgopong" 

replace ANCvote2016 =0.60 if Local_Mu=="Moqhaka" 
replace DAvote2016 =0.25 if Local_Mu=="Moqhaka" 

replace ANCvote2016 =0.66 if Local_Mu=="Moses Kotane" 
replace DAvote2016 =0.05 if Local_Mu=="Moses Kotane" 

replace ANCvote2016 =0.26 if Local_Mu=="Mossel Bay" 
replace DAvote2016 =0.61 if Local_Mu=="Mossel Bay" 

replace ANCvote2016 =0.73 if Local_Mu=="Mpofana" 
replace DAvote2016 =0.14 if Local_Mu=="Mpofana" 

replace ANCvote2016 =0.74 if Local_Mu=="Mutale" 
replace DAvote2016 =0.13 if Local_Mu=="Mutale" 

replace ANCvote2016 =0.62 if Local_Mu=="Ndlambe" 
replace DAvote2016 =0.31 if Local_Mu=="Ndlambe" 

replace ANCvote2016 =0.41 if Local_Mu=="Nelson Mandela Bay" 
replace DAvote2016 =0.47 if Local_Mu=="Nelson Mandela Bay" 

replace ANCvote2016 =0.61 if Local_Mu=="Newcastle" 
replace DAvote2016 =0.09 if Local_Mu=="Newcastle" 

replace ANCvote2016 =0.83 if Local_Mu=="Ngquza Hill" 
replace DAvote2016 =0.04 if Local_Mu=="Ngquza Hill" 

replace ANCvote2016 =0.65 if Local_Mu=="Ngwathe" 
replace DAvote2016 =0.23 if Local_Mu=="Ngwathe" 

replace ANCvote2016 =0.83 if Local_Mu=="Nkomazi" 
replace DAvote2016 =0.06 if Local_Mu=="Nkomazi" 

replace ANCvote2016 =0.84 if Local_Mu=="Nyandeni" 
replace DAvote2016 =0.04 if Local_Mu=="Nyandeni" 

replace ANCvote2016 =0.52 if Local_Mu=="Okhahlamba" 
replace DAvote2016 =0.06 if Local_Mu=="Okhahlamba" 

replace ANCvote2016 =0.27 if Local_Mu=="Oudtshoorn" 
replace DAvote2016 =0.55 if Local_Mu=="Oudtshoorn" 

replace ANCvote2016 =0.31 if Local_Mu=="Overstrand" 
replace DAvote2016 =0.64 if Local_Mu=="Overstrand" 

replace ANCvote2016 =0.60 if Local_Mu=="Phokwane" 
replace DAvote2016 =0.18 if Local_Mu=="Phokwane" 

replace ANCvote2016 =0.78 if Local_Mu=="Pixley Ka Seme" 
replace DAvote2016 =0.11 if Local_Mu=="Pixley Ka Seme" 

replace ANCvote2016 =0.57 if Local_Mu=="Polokwane" 
replace DAvote2016 =0.11 if Local_Mu=="Polokwane" 

replace ANCvote2016 =0.60 if Local_Mu=="Ramotshere Moiloa" 
replace DAvote2016 =0.06 if Local_Mu=="Ramotshere Moiloa" 

replace ANCvote2016 =0.52 if Local_Mu=="Renosterberg" 
replace DAvote2016 =0.42 if Local_Mu=="Renosterberg" 

replace ANCvote2016 =0.49 if Local_Mu=="Rustenburg" 
replace DAvote2016 =0.16 if Local_Mu=="Rustenburg" 

replace ANCvote2016 =0.58 if Local_Mu=="Sol Plaatjie" 
replace DAvote2016 =0.30 if Local_Mu=="Sol Plaatjie" 

replace ANCvote2016 =0.20 if Local_Mu=="Stellenbosch" 
replace DAvote2016 =0.69 if Local_Mu=="Stellenbosch" 

replace ANCvote2016 =0.24 if Local_Mu=="Swartland" 
replace DAvote2016 =0.70 if Local_Mu=="Swartland" 

replace ANCvote2016 =0.66 if Local_Mu=="The Msunduzi" 
replace DAvote2016 =0.19 if Local_Mu=="The Msunduzi" 

replace ANCvote2016 =0.36 if Local_Mu=="Theewaterskloof" 
replace DAvote2016 =0.51 if Local_Mu=="Theewaterskloof" 

replace ANCvote2016 =0.79 if Local_Mu=="Thulamela" 
replace DAvote2016 =0.05 if Local_Mu=="Thulamela" 

replace ANCvote2016 =0.51 if Local_Mu=="Tlokwe City Council" 
replace DAvote2016 =0.32 if Local_Mu=="Tlokwe City Council" 

replace ANCvote2016 =0.66 if Local_Mu=="Tokologo" 
replace DAvote2016 =0.13 if Local_Mu=="Tokologo" 

replace ANCvote2016 =0.68 if Local_Mu=="Tswaing" 
replace DAvote2016 =0.17 if Local_Mu=="Tswaing" 

replace ANCvote2016 =0.72 if Local_Mu=="UMuziwabantu" 
replace DAvote2016 =0.04 if Local_Mu=="UMuziwabantu" 

replace ANCvote2016 =0.76 if Local_Mu=="Ubuhlebezwe" 
replace DAvote2016 =0.03 if Local_Mu=="Ubuhlebezwe" 

replace ANCvote2016 =0.60 if Local_Mu=="Umdoni" 
replace DAvote2016 =0.18 if Local_Mu=="Umdoni" 

replace ANCvote2016 =0.58 if Local_Mu=="Umhlabuyalingana" 
replace DAvote2016 =0.02 if Local_Mu=="Umhlabuyalingana" 

replace ANCvote2016 =0.76 if Local_Mu=="Umjindi" 
replace DAvote2016 =0.14 if Local_Mu=="Umjindi" 

replace ANCvote2016 =0.49 if Local_Mu=="Umtshezi" 
replace DAvote2016 =0.04 if Local_Mu=="Umtshezi" 

replace ANCvote2016 =0.54 if Local_Mu=="Umvoti" 
replace DAvote2016 =0.04 if Local_Mu=="Umvoti" 

replace ANCvote2016 =. if Local_Mu=="Vulamehlo" 
replace DAvote2016 =. if Local_Mu=="Vulamehlo" 

replace ANCvote2016 =0.53 if Local_Mu=="Westonaria" 
replace DAvote2016 =0.27 if Local_Mu=="Westonaria" 

replace ANCvote2016 =0.56 if Local_Mu=="eThekwini" 
replace DAvote2016 =0.27 if Local_Mu=="eThekwini" 

replace ANCvote2016 =0.64 if Local_Mu=="uMhlathuze" 
replace DAvote2016 =0.12 if Local_Mu=="uMhlathuze" 

replace ANCvote2016 =0.55 if Local_Mu=="uMlalazi" 
replace DAvote2016 =0.02 if Local_Mu=="uMlalazi" 

replace ANCvote2016 =0.56 if Local_Mu=="uMngeni" 
replace DAvote2016 =0.41 if Local_Mu=="uMngeni" 

**generate vote margin (absolute)
gen vm = ANCvote2016 - DAvote2016
gen votemargin = (abs(vm)*100)

************************************* End ************************************* 


